# app/utils/db_utils.py
import asyncio
import logging
from app.main import db_task_queue  # 注意：这里我们只导入 db_task_queue，而不是整个 app.main

logger = logging.getLogger(__name__)

async def safe_db_operation(func):
    """安全的数据库操作"""
    loop = asyncio.get_event_loop()
    return await loop.run_in_executor(None, lambda: db_task_queue.put(func))